package com.txh.blog.service.impl;

import com.txh.blog.mapper.LinkMapper;
import com.txh.blog.model.Link;
import com.txh.blog.service.LinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class LinkServiceImpl implements LinkService {
    @Autowired
    private LinkMapper linkMapper;
    @Override
    public Map<String,Object> allLinks() {
        Map<String,Object> page = new HashMap<>();
        List<Link> links=linkMapper.selectAll();
        page.put("list",links);
        page.put("total",links.size());
        return page;
    }

    @Override
    public void delLinkById(Long id) {
        linkMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void addLink(Link link) {
        linkMapper.insert(link);
    }
}
